package com.xunge.mapper;

import com.xunge.pojo.Exam;
import com.xunge.pojo.ExamQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExamMapper {

    /**
     * 分页查询考试信息
     */
    List<Exam> list(ExamQueryParam examQueryParam);

    /**
     * 新增考试
     */
    @Insert("insert into exam(title, course_id, clazz_id, exam_type, exam_date, duration, location, status, create_time, update_time) " +
            "values(#{title}, #{courseId}, #{clazzId}, #{examType}, #{examDate}, #{duration}, #{location}, #{status}, now(), now())")
    void insert(Exam exam);

    /**
     * 根据ID查询考试
     */
    @Select("select * from exam where id = #{id}")
    Exam getById(Integer id);

    /**
     * 根据ID修改考试
     */
    void update(Exam exam);

    /**
     * 根据ID删除考试
     */
    @Delete("delete from exam where id = #{id}")
    void deleteById(Integer id);

    /**
     * 批量删除考试
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 根据课程ID查询考试
     */
    @Select("select * from exam where course_id = #{courseId}")
    List<Exam> getByCourseId(Integer courseId);

    /**
     * 根据班级ID查询考试
     */
    @Select("select * from exam where clazz_id = #{clazzId}")
    List<Exam> getByClazzId(Integer clazzId);
} 